home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 49
/
Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso
/
-serious-
/
misc
/
football
/
exec
/
lstats.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-11-29
|
23KB
|
814 lines
/* ***********************************************************************
LEAGUE STATS PROGRAM FOR FOOTBALL REXX SUITE
----------------------------------------------
Copyright Mark Naughton 1996
Version Date History
--------------------------------------------------------------------------
1.0 211196 First release. Displays info about the league and then
the best record/performance in the league.
211196 Steve Holland has helped immensely in improving the
display and in what stats to display.
1.1 110497 Added code to support Points_Per_Goals.
120497 Removed code that adds Points for Goals as the
performance options were too far out. A team with a
246% record out of 5 matches is too much. Points Per
Goals is now mentioned but is NOT used.
160597 Amended way the number of matches is incremented. Was
adding an extra one.
1.2 250997 Added code for promotions and divisions.
071297 Amended Highest Home/Away win as 7-0 should be better
than 7-2.
151297 Tidied display.
160998 Added code to give priority to teams with less goals
scored against them. Added code to display all matches
which match the highest home/away scores.
250199 Fixed bugs in calculating the biggest wins where if the
match had a clean sheet, no other match could top it
unless they had a clean sheet and scored more goals.
250499 Fixed bug where percentages couldn't be calculated if
the results/matches were zero.
1.3 270699 Added code for top scorers, fair play table, highest
and lowest attendances and the fastest goal.
1.4 120899 New variable "prerstring". Search for "heiko" ;-)
localized texts you can see at "txt_...". Update by
Heiko Schroder.
1.41 160899 Attends of all matches and divided to one match (sum_attd)
Update by Heiko Schroder. Redesigned display.
250899 Added error msg to file checks.
270899 Converted to use locale. Some error messages, before
reading the locale, will still be in English.
Heiko has produced localised this script. Amendments
made including localising errors and adding the same
locale data-read code.
010999 More tidying up. Top scorers now do not show own goals.
110999 Tidied display again - fixed bug where the first
character of the undefeated team was overwritten.
141099 Yellow-Red cards are now handled properly.
**************************************************************************
Procedure
---------
1. Check files exist. Open 'Teams.df' file and read data into array/variables.
2. Open Learn file and read a line.
3. Store data on the teams that played a match (Win/Draw/Loss) for Record
and Performance.
4. Store stats for the league.
5. Calculate the biggest win/loss.
6. Read Learn file and produce stats on scorers, cards and attendances. If
required, write data to file for sorting.
6. Format data produced for Record and Performance.
7. Display data then exit...
************************************************************************** */
PARSE ARG league_stuff
version = 1
input_file = '.df'
input2_file = '.sflearn'
title = '*LEAGUE_NAME='
points_win = '*POINTS_PER_WIN='
points_drw = '*POINTS_PER_DRW='
points_lse = '*POINTS_PER_LSE='
points_gls = '*POINTS_PER_GLS='
releg = '*RELEGATION='
playother = '*PLAY_OTHER='
promoted = '*PROMOTED='
num_divs = '*NUM_DIVISIONS='
divisions = '*DIVISIONS='
pkauthor = '* Author ='
pkversion = '* Version='
pkdate = '* Date ='
separator = '*'
not_played = '__ __'
teams. = '???'
records. = '???'
undefeat. = '???'
ustring. = '???'
rstring. = '???'
mats. = '???'
pct. = '???'
tcount = 0
lversion = '1.0'
lreg = 2
lplayo = 2
ptsgls = 0
ndivs = 1
promo = 0
divs = ''
home_def = '*HG='
away_def = '*AG='
yellowc = 'Y='
redc = 'R='
yredc = 'YR='
attd_def = '*ATD='
sum_attd = 0
goalsc. = '???'
goalscorers. = '???'
goalss. = '???'
gscount = 0
gscounter = 0
fgoal = 300
fmatch = ""
fscorer = ""
hamatch = ""
hanum = 0
lamatch = ""
lanum = 999999999
ycards. = '???'
rcards. = '???'
fside = 0
empty = ""
parse var league_stuff league_file
league_file = "Data/" || league_file
if open(datafile,"Data/Football.locale",'r') then do
line = readln(datafile)
locdir = strip(line)
close(datafile)
end
else do
say
say "ERROR : (LStats / League Information)"
say
say "Cannot read 'Data/Football.locale' for the locale settings."
exit
end
dfordir = locdir"Football.locale_data"
locdir = locdir"Exec/LStats.data"
if open(datafile,"ENV:FootballRXPath",'r') then do
line = readln(datafile)
rxdir = strip(line)
close(datafile)
end
else
rxdir = "SYS:Rexxc/"
if exists(locdir) > 0 then do
address command rxdir'rx 'locdir
VarCount = getclip('VarCount')
do i = 1 to VarCount
interpret getclip('var.'i)
end
end
else do
say
say "ERROR : (LStats / League Information)"
say
say "Cannot find '"locdir"' to read locale settings."
exit
end
if exists(dfordir) > 0 then do
address command rxdir'rx 'dfordir
VarCount = getclip('VarCount')
do i = 1 to VarCount
interpret getclip('var.'i)
end
end
else do
say
say "ERROR : (Stats)"
say
say "Cannot find '"dfordir"' to read date locale settings."
exit
end
if exists(league_file || input_file) = 0 then do
say
say txt_error
say
say txt_ls1"'"league_file||input_file"'."
exit
end
if exists(league_file || input2_file) = 0 then do
say
say txt_error
say
say txt_ls1"'"league_file||input2_file"'."
exit
end
if open(datafile,league_file || input_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(title,line) > 0 then league_title = delstr(line,1,13)
if pos(pkauthor,line) > 0 then author = delstr(line,1,12)
if pos(pkversion,line) > 0 then lversion = delstr(line,1,12)
if pos(pkdate,line) > 0 then ddate = delstr(line,1,12)
if pos(points_win,line) > 0 then ptswin = delstr(line,1,16)
if pos(points_drw,line) > 0 then ptsdrw = delstr(line,1,16)
if pos(points_lse,line) > 0 then ptslse = delstr(line,1,16)
if pos(points_gls,line) > 0 then ptsgls = delstr(line,1,16)
if pos(releg,line) > 0 then lreg = delstr(line,1,12)
if pos(playother,line) > 0 then lplayo = delstr(line,1,12)
if pos(promoted,line) > 0 then promo = delstr(line,1,10)
if pos(num_divs,line) > 0 then ndivs = delstr(line,1,15)
if pos(divisions,line) > 0 then divs = delstr(line,1,11)
if pos(separator,line) = 0 then do
line = strip(line)
tcount = tcount + 1
teams.tcount = line
records.tcount = 0
undefeat.tcount= ''
mats.tcount = 0
pct.tcount = 0
end
end
close(datafile)
end
else do
say
say txt_error
say
say txt_ls2"'"league_file||input_file"'"txt_ls4
exit
end
line_ct = 0
matches = 0
high_df = 0
high_ht = ''
high_at = ''
high_hw = 0
high_aw = 0
high_hs = 0
high_as = 0
draws = 0
hwins = 0
awins = 0
type = 0
hcls = 99
acls = 99
nlines. = '???'
nlcnt = 0
if open(datafile,league_file || input2_file,'r') then do
do while ~eof(datafile)
line_ct = line_ct + 1
line = readln(datafile)
if pos(separator,line) = 0 then do
if pos(not_played,line) = 0 then do
home_team = strip(substr(line,1,30))
goals_for = substr(line,32,2)
goals_aga = substr(line,37,2)
away_team = strip(substr(line,41,30))
call save_data(home_team,away_team,goals_for,goals_aga)
if home_team ~= away_team & home_team ~= '' & away_team ~= '' then
matches = matches + 1
diff = 0
if goals_for = goals_aga & home_team ~= away_team then do
draws = draws + 1
type = 0
end
if goals_for > goals_aga then do
hwins = hwins + 1
diff = goals_for - goals_aga
type = 1
end
if goals_for < goals_aga then do
awins = awins + 1
diff = goals_aga - goals_for
type = 2
end
if type = 1 then do
if diff >= high_hw then do
nlcnt = nlcnt + 1
nlines.nlcnt = line
if ((goals_for > high_hs) | (diff = goals_for)) | (diff = high_hw & goals_aga <= hcls) then do
high_hw = diff
hcls = goals_aga
high_hs = goals_for
high_ht = line
end
end
end
if type = 2 then do
if diff >= high_aw then do
nlcnt = nlcnt + 1
nlines.nlcnt = line
if ((goals_aga > high_as) | (diff = goals_aga)) | (diff = high_aw & goals_for <= acls) then do
high_as = goals_aga
high_at = line
high_aw = diff
acls = goals_for
end
end
end
type = 0
end
end
end
close(datafile)
end
else do
say
say txt_error
say
say txt_ls2"'"league_file||input2_file"'"txt_ls4
exit
end
/* code to check for top goal scorer and attendances */
yellred = 0
do ii=1 to tcount
ycards.ii = 0
rcards.ii = 0
end
j = 0
if open(datafile,league_file || input2_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(separator,line) = 0 then do
if pos(not_played,line) = 0 then do
j = 0
home_team = strip(substr(line,1,30))
goals_for = substr(line,32,2)
goals_aga = substr(line,37,2)
away_team = strip(substr(line,41,30))
j = 1
end
end
else do
if j > 0 & pos("(og)",line) = 0 then do
if pos(home_def,line) > 0 then do
gscount = gscount + 1
parse var line "*HG=" goalsc.gscount
/* Heiko, Team of Goaler */
goalsc.gscount.1 = home_team
/* END */
end
if pos(away_def,line) > 0 then do
gscount = gscount + 1
parse var line "*AG=" goalsc.gscount
goalsc.gscount.1 = away_team
/* END */
end
if pos(yellowc,line) > 0 & pos(yredc,line) = 0 then do
if pos("*H",line) > 0 then
searchfp = home_team
else
searchfp = away_team
do ii=1 to tcount
if pos(searchfp,teams.ii) > 0 then
ycards.ii = ycards.ii + 1
end
yellred = 1
end
if pos(yredc,line) > 0 then do
if pos("*H",line) > 0 then
searchfp = home_team
else
searchfp = away_team
do ii=1 to tcount
if pos(searchfp,teams.ii) > 0 then do
ycards.ii = ycards.ii + 1
rcards.ii = rcards.ii + 1
end
end
yellred = 1
end
if pos(redc,line) > 0 & pos(yredc,line) = 0 then do
if pos("*H",line) > 0 then
searchfp = home_team
else
searchfp = away_team
do ii=1 to tcount
if pos(searchfp,teams.ii) > 0 then
rcards.ii = rcards.ii + 1
end
yellred = 1
end
if pos("G=",line) > 0 then do
if pos("(P)",line) > 0 then do
kl = pos("(P)",line)
goalsc.gsc = delstr(line,kl,3)
end
klk = words(line)
if datatype(word(line,klk)) = "NUM" then do
if word(line,klk) < fgoal then do
ffscorer = delword(line,klk,1)
parse var ffscorer . "G=" fscorer
fgoal = word(line,klk)
fmatch= home_team" "right(goals_for,2)" "right(goals_aga,2)" "away_team
if pos("*HG=",ffscorer) > 0 then fside = 1
if pos("*AG=",ffscorer) > 0 then fside = 2
end
end
end
if pos(attd_def,line) > 0 then do
parse var line "*ATD=" attend
if attend > hanum then do
hanum = attend
hamatch = home_team || txt_versus || away_team
end
if attend < lanum then do
lanum = attend
lamatch = home_team || txt_versus || away_team
end
sum_attd=sum_attd+attend
end
end
end
end
close(datafile)
end
else do
say
say txt_error
say
say txt_ls3"'"league_file || input2_file"'."
exit
end
if gscount > 0 then do
do gsc=1 to gscount
if pos("(P)",goalsc.gsc) > 0 then do
kl = pos("(P)",goalsc.gsc)
goalsc.gsc = delstr(goalsc.gsc,kl,3)
end
klk = words(goalsc.gsc)
if datatype(word(goalsc.gsc,klk)) = "NUM" then
goalsc.gsc = delword(goalsc.gsc,klk,1)
end
do gsc=1 to gscount
name = goalsc.gsc
team = goalsc.gsc.1
notin = 0
do ii=1 to gscounter
if pos(name,goalscorers.ii) > 0 then do
goalss.ii = goalss.ii + 1
notin = 1
end
end
if notin = 0 then do
gscounter = gscounter + 1
goalscorers.gscounter = name
/* Heiko, Team of Goaler */
goalscorers.gscounter.1 = team
/* End */
goalss.gscounter = 1
end
end
end
if gscounter > 1 then do
if open(datafile,"RAM:Football.tempcup",'w') then do
do ii=1 to gscounter
/* Heiko, Team of Goaler */
writeln(datafile,left(goalss.ii,4)" "goalscorers.ii" "goalscorers.ii.1)
/* end */
end
close(datafile)
end
else do
say
say txt_error
say
say txt_ls5
exit
end
address command 'Exec/Sort4Chars '
address command 'c:Rename >NIL: RAM:Football.tempcup as RAM:Football.tempcup2'
end
if open(datafile,"RAM:Football.tempcup",'w') then do
do ii=1 to tcount
writeln(datafile,left(ycards.ii+(rcards.ii*2),4)" "left(teams.ii,30)" "right(ycards.ii,4)" "right(rcards.ii,4))
end
close(datafile)
end
else do
say
say txt_error
say
say txt_ls5
exit
end
address command 'Exec/Sort4Chars '
r = 0
rc = 0
u = 1
uc = 0
do i=1 to tcount
if records.i ~= 0 | mats.i ~= 0 then do
pct.i = trunc((records.i/(mats.i*ptswin) * 100),1)
if pct.i > r then r = pct.i
end
else
pct.i = "0.0"
end
do i=1 to tcount
if pct.i = r then do
rc = rc + 1
/* changes by Heiko */
prerstring = records.i || txt_brecord1 || mats.i || txt_brecord2 || pct.i || txt_brecord3
rstring.rc = teams.i
/* end changes by Heiko */
end
end
do i=1 to tcount
if length(undefeat.i) > u then
u = length(undefeat.i)
end
do i=1 to tcount
if length(undefeat.i) = u then do
uc = uc + 1
undefeat.i=strip(undefeat.i)
ucn = (length(undefeat.i) * 2) - 1
call format_perf(undefeat.i,ucn)
if ucn = 1 then ptemp = undefeat.i
if length(ptemp) > 0 then
ustring.uc = " " || left(teams.i,30) || " (" || ptemp || ")"
end
end
hmw = trunc((hwins/matches) * 100,1)
dm = trunc((draws/matches) * 100,1)
amw = trunc((awins/matches) * 100,1)
/* Heiko */
hwins = centre(hwins,2)
draws = centre(draws,2)
awins = centre(awins,2)
say
say center(txt_league_title||league_title,78)
say "-------------------------------------------------------------------------------"
say
say " "txt_author || author
say " "txt_ddate || ddate
say " "txt_lversion || lversion
say
say txt_matches || matches
say
say txt_hwins || hwins" ( "hmw"% )"
say txt_draws || draws" ( "dm"% )"
say txt_awins || awins" ( "amw"% )"
say
attd_int=trunc(sum_attd/matches,0)
say txt_sum_attd || sum_attd
say txt_sum_attd2 || insert(" ",attd_int,0,Length(sum_attd)-Length(attd_int))
say
say txt_ptswin || ptswin
say txt_ptsdrw || ptsdrw
say txt_ptslse || ptslse
say txt_ptsgls || ptsgls " "txt_ls8
say
say txt_promo || promo
say txt_lreg || lreg
say txt_lplayo || lplayo
say
say txt_ls6""ndivs - 1
say txt_ls7""divs
say "_______________________________________________________________________________"
say
if gscounter > 0 then do
say txt_topgoal
say txt_topgoal_line
say txt_topgoal1
say txt_topgoal1_line
if gscounter = 1 then do
say " 1) " right(goalss.1,2) " "strip(goalscorers.1)" ("goalscorers.1.1")"
say
end
else do
ii = 0
if open(datafile,"RAM:Football.tempcup2",'r') then do
do while ~eof(datafile)
line = readln(datafile)
if line ~= "" & ii < 10 then do
parse var line total player rest
ii = ii + 1
/* Heiko, Team of Goaler */
say " "right(ii,2)") " right(strip(total,'T'),2) " "strip(player)" ("strip(rest)")"
/* end */
end
end
close(datafile)
say
end
else do
say
say txt_error
say
say txt_ls9
say
end
address command 'delete >NIL: RAM:Football.tempcup2'
end
end
if yellred > 0 then do
ii = 0
if open(datafile,"RAM:Football.tempcup",'r') then do
do while ~eof(datafile)
line = readln(datafile)
if line ~= "" then do
parse var line total rest
ii = ii + 1
ycards.ii = strip(rest)" "right(total,5)
end
end
close(datafile)
say
end
else do
say
say txt_error
say
say txt_ls10
say
end
address command 'delete >NIL: RAM:Football.tempcup'
say
say txt_fplay
say txt_fplay_line
say txt_fplay1
say txt_fplay1_line
do ii=1 to tcount
say right(ii,3)") "ycards.ii
end
say
say
end
if gscounter > 0 | yellred > 0 then do
say "_______________________________________________________________________________"
say
end
say txt_brecord
say txt_brecord_line
/* changes by Heiko */
rstring.1 = insert(prerstring,rstring.1,0)
empty = insert(" ",empty,0,length(prerstring))
do i=1 to tcount
if rstring.i ~= "" & rstring.i ~= '???' then
if i = 1 then say rstring.i
else say empty || rstring.i
end
/* end changes by Heiko */
say
say txt_cbur
say txt_cbur_line
say
/* ustring.1 = overlay(u || txt_match3,ustring.1,1) */
ustring.1 = u || txt_match3||strip(ustring.1)
do i=1 to uc
if i=1 then say ustring.i
else say " "ustring.i
end
say
say "-------------------------------------------------------------------------------"
say
say txt_bhw
say txt_bhw_line
hline = substr(high_ht,32,2)" "substr(high_ht,37,2)
if hline ~= "" then do
do i=1 to nlcnt
if pos(hline,nlines.i) > 0 then
say nlines.i
end
end
else
say txt_ls11
say
say
say txt_baw
say txt_baw_line
aline = substr(high_at,32,2)" "substr(high_at,37,2)
if aline ~= "" then do
do i=1 to nlcnt
if pos(aline,nlines.i) > 0 then
say nlines.i
end
end
else
say txt_ls11
say
say
if hanum > 0 then do
say txt_hatt
say txt_hatt_line
say txt_crowd || hanum
say txt_match || hamatch
say
say
end
if lanum ~= 999999999 then do
say txt_latt
say txt_latt_line
say txt_crowd || lanum
say txt_match || lamatch
say
say
end
if fgoal ~= 300 then do
say txt_fgoal
say txt_fgoal_line
if fside = 0 then fsside = txt_fside0
if fside = 1 then fsside = txt_fside1
if fside = 2 then fsside = txt_fside2
say txt_player || strip(fscorer) || txt_fgoal1 || fgoal || txt_fgoal2 || fsside
say txt_match2 ||fmatch
say
say
end
say "_______________________________________________________________________________"
exit
/* Routine ---------------------------------------------------------- */
save_data:
PARSE ARG homet,awayt,gf,ga
h = 0
a = 0
do i=1 to tcount
if pos(strip(homet),teams.i) > 0 then do
h = i
mats.i = mats.i + 1
end
if pos(strip(awayt),teams.i) > 0 then do
mats.i = mats.i + 1
a = i
end
end
if a = 0 | h = 0 then return
if gf > ga then do
records.h = records.h + ptswin
records.a = records.a + ptslse
undefeat.h = insert(txt_w,undefeat.h,length(undefeat.h),1)
undefeat.a = ''
end
if gf < ga then do
records.a = records.a + ptswin
records.h = records.h + ptslse
undefeat.a = insert(txt_w,undefeat.a,length(undefeat.a),1)
undefeat.h = ''
end
if gf = ga then do
records.a = records.a + ptsdrw
records.h = records.h + ptsdrw
undefeat.a = insert(txt_d,undefeat.a,length(undefeat.a),1)
undefeat.h = insert(txt_d,undefeat.h,length(undefeat.h),1)
end
/*
records.a = records.a + (ga * ptsgls) PTS_PER_GLS - NOT USED FOR PERFORMANCE...
records.h = records.h + (gf * ptsgls)
*/
return
/* Routine ---------------------------------------------------------- */
format_perf:
ARG fstrg,counter
ptemp = ''
ii = 1
jj = 1
do while ii <= counter
ptemp = insert(substr(fstrg,jj,1),ptemp,ii,1)
ii = ii + 1
jj = jj + 1
if ii < counter then do
ptemp = insert(".",ptemp,ii,1)
ii = ii + 1
end
end
ptemp = strip(ptemp)
return
/* ------------------------------------------------------------------ */